<!-- questionList.html 2017-09-30 00:09:05-->
#@HplusLayout()
#define content()
<div class="gray-bg" style="padding:0 10px;height: 100%">
	<div class="row">
		<div class="col-xs-3" style="padding-top: 10px">		
			<div class="ibox">
				<div class="ibox-title">
					<h5>分类目录</h5>
					<div class="pull-right">
						<a href="javascript:" style="font-size:12px;color: #666" onclick="expandAll(true);" title="全部展开">展开</a>
						 <a href="javascript:" style="font-size:12px;color: #666" onclick="expandAll(false);" title="全部展开">收起</a>
					</div>
				</div>
				<div class="ibox-content">
					<ul id="ZTree" class="ztree"></ul>
				</div>
			</div>	
		</div>
		<div class="col-xs-9" style="background-color: #fff;">
			<div id="AdvanceSearch" style="padding:15px;display: none">
				<form class="form-horizontal" novalidate="novalidate" onsubmit="return bootstrapTableRefresh()">
					<input type="hidden" value="" name="num"/>
										<div class="form-group">
						<label class="col-xs-3 control-label">标题：</label>
						<div class="col-xs-8">
	<input type="text" class="form-control" name="title"/>
						</div>
					</div>
			    					<div class="form-group">
						<label class="col-xs-3 control-label">状态：</label>
						<div class="col-xs-8">
<select name="status" class="form-control">
	<option value="">请选择</option>
	#(data("ASK_STATUS","option",""))
</select>
						</div>
					</div>
			    					<div class="form-group">
						<label class="col-xs-3 control-label">是否通过：</label>
						<div class="col-xs-8">
	<label style="font-weight:normal;line-height: 35px"><input type="radio" name="is_pass" checked="checked" value=""/> 全部 </label>
	#for(item:data("SHIFOU"))
	<label style="font-weight:normal;line-height: 35px;margin-bottom: 0px;"><input type="radio" name="is_pass" value="#(item.key)"/> #(item.value.name) </label>
	#end
						</div>
					</div>
			    					<div class="form-group">
						<label class="col-xs-3 control-label">状态：</label>
						<div class="col-xs-8">
	<label style="font-weight:normal;line-height: 35px"><input type="radio" name="enable_flag" checked="checked" value=""/> 全部 </label>
	#for(item:data("ENABLE_FLAG"))
	<label style="font-weight:normal;line-height: 35px;margin-bottom: 0px;"><input type="radio" name="enable_flag" value="#(item.key)"/> #(item.value.name) </label>
	#end
						</div>
					</div>
			    					<div class="form-group">
						<div class="col-xs-8 col-xs-offset-3">
							<button type="reset" class="btn btn-default">清空</button> 
							<button type="submit" class="btn btn-primary">开始查询</button> 
						</div>
					</div>
				</form>
			</div>
			<div id="toolbar">
				<button onclick="layer.open({area: ['450px', 'auto'],content:$('#AdvanceSearch'),type:1,shade: false,title:'搜索'});" type="button" class="btn btn-outline btn-default"><i class="glyphicon glyphicon-search"></i></button>
				<a href="batchDeleteQuestion" class="btn btn-outline btn-default" target="selectedTodo" rel="btSelectItem" title="确定删除这些数据？"><i class="glyphicon glyphicon-trash"></i></a>
			</div>
			<table id="bootstrapTable" data-id-field="id" data-url="questionList?catalog_id=#(catalog_id)" data-sort-name="id" data-sort-order="desc">
				<thead>
					<tr>
						<th data-checkbox="true"></th>
						<th data-formatter="xuhaoFormatter" data-align="center" data-width="70px">序号</th>
						<th data-field="catalog_name" data-align="center">分类</th>
						<th data-field="title">标题</th>
						<th data-field="status_cn" data-align="center">状态</th>
						<th data-field="answer_count" data-align="center">回答量</th>
						<th data-field="is_pass_cn" data-align="center">是否通过</th>
						<th data-field="create_user_name" data-align="center">提问人</th>
						<th data-field="create_time" data-align="center" data-width="150px">提问时间</th>
						<th data-formatter="caozuoFormatter">操作</th>
					</tr>
				</thead>
			</table>
		</div>
	</div>
</div>
#end
#define css()
<link href="#(res_path)/hplus/css/plugins/ztree/metroStyle/metroStyle.css" rel="stylesheet">
<link href="#(res_path)/hplus/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
#end
#define js()
<script src="#(res_path)/hplus/js/plugins/ztree/jquery.ztree.all.min.js"></script>
<script src="#(res_path)/hplus/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
<script src="#(res_path)/hplus/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
#end
#define jsFunction()
<script>
		var zNodes = #(listJSON??"[]");
		
		$().ready(function() {
			$.fn.zTree.init($("#ZTree"), {
				data: {
					simpleData: {
						enable: true
					}
				},
				callback:{
					onClick:treeOnClick
				}
			}, zNodes);
		});
		var catalog_id = 0;
		function treeOnClick(event, treeId, treeNode){
			catalog_id = treeNode.id;
		  $("#AdvanceSearch form").find("input[name='num']").val(treeNode.num);
		  $("#AdvanceSearch form").submit();
		}
		function openAddEdit(){
		  if(catalog_id==0){
			  layer.alert("请先选择分类！",{icon:2});
			  return;
		  }
				layer.open({area: ['550px', '300px'],content: 'addEditQuestion?catalog_id='+catalog_id,type: 2,title: '新增'});
		}
		function expandAll(flag){
			var treeObj = $.fn.zTree.getZTreeObj("ZTree");
			treeObj.expandAll(flag);
		}
	function caozuoFormatter(value,row,index){
		var str = "";
		str = str + "<a href=\"javascript:\" onclick=\"layer.open({area: ['550px', '300px'],content: 'addEditQuestion?id="+row.id+"',type: 2,title: '编辑问题'});\">编辑</a>  ";
		str = str + "<a href=\"javascript:\" onclick=\"layer.full(layer.open({content: 'answerList?question_id="+row.id+"',type: 2,title: '回答列表'}));\">回答列表</a>  ";
		
		return str;
	}
</script>
#end